package txunda.com.decoratemaster.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import administrator.example.com.framing.BaseActivity;
import administrator.example.com.framing.BaseFragment;
import administrator.example.com.framing.interfaces.Layout;
import administrator.example.com.framing.util.JumpParameter;
import administrator.example.com.framing.util.OnResponseListener;
import txunda.com.decorate.R;
import txunda.com.decorate.application.MyApplication;


public abstract class BaseFgt extends BaseFragment {
    /**
     * 项目的application
     */
    protected MyApplication application;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public boolean jump(Class<?> cls) {
        jumpAnim(R.anim.slide_in_right, R.anim.slide_out_left);
        return super.jump(cls);
    }

    @Override
    public boolean jump(Class<?> cls, JumpParameter jumpParameter) {
        jumpAnim(R.anim.slide_in_right, R.anim.slide_out_left);
        return super.jump(cls, jumpParameter);
    }

    @Override
    public boolean jump(Class<?> cls, OnResponseListener onResponseListener) {
        return super.jump(cls, onResponseListener);
    }

    @Override
    public boolean jump(Class<?> cls, JumpParameter jumpParameter, OnResponseListener onResponseListener) {
        return super.jump(cls, jumpParameter, onResponseListener);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        try {
            Layout layout = (Layout) this.getClass().getAnnotation(Layout.class);
            if (layout == null) {
                this.layoutResId = this.getLayout();
            } else {
                if (layout.value() == -1) {
                    throw new Exception("请在您的Fragment的Class上注解：@Layout(你的layout资源id)");
                }

                this.layoutResId = layout.value();
            }
        } catch (Exception var5) {
            var5.printStackTrace();
        }

        this.rootView = LayoutInflater.from(this.getActivity()).inflate(this.layoutResId, null, false);
        this.me = (BaseActivity) this.getActivity();
        application = (MyApplication) me.getApplication();
        this.initViews();
        this.initDatas();
        this.setEvents();
        return this.rootView;
    }

//    public void setAlias(String token, String m_id, String type) {
//        String alias = token;
//        Set<String> tags = new HashSet<String>();
//        tags.add(token + "_" + type);
//        L.e("data.get(\"token\")", token);
//        boolean isAliasAction = false;
//        int action = -1;
//        action = ACTION_SET;
//        TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
//        tagAliasBean.action = action;
//        int jpusuid = 0;
//        try {
//            jpusuid = Integer.parseInt(m_id);
//        } catch (NumberFormatException e) {
//            e.printStackTrace();
//        }
//        if (isAliasAction) {
//            tagAliasBean.alias = alias;
//        } else {
//            tagAliasBean.tags = tags;
//        }
//        tagAliasBean.isAliasAction = isAliasAction;
//        TagAliasOperatorHelper.getInstance().handleAction(getActivity(), jpusuid, tagAliasBean);
//    }

}
